/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author roycalderon
 */
@Entity
@Table(name = "Dia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dia.findAll", query = "SELECT d FROM Dia d"),
    @NamedQuery(name = "Dia.findByFecha", query = "SELECT d FROM Dia d WHERE d.diaPK.fecha = :fecha"),
    @NamedQuery(name = "Dia.findByEmpleadoidEmpleado", query = "SELECT d FROM Dia d WHERE d.diaPK.empleadoidEmpleado = :empleadoidEmpleado"),
    @NamedQuery(name = "Dia.findByObservacion", query = "SELECT d FROM Dia d WHERE d.observacion = :observacion")})
public class Dia implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DiaPK diaPK;
    @Size(max = 200)
    @Column(name = "observacion")
    private String observacion;
    @JoinColumn(name = "Estado_idEstado", referencedColumnName = "idEstado")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estadoidEstado;
    @JoinColumn(name = "Turno_idTurno", referencedColumnName = "idTurno")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Turno turnoidTurno;
    @JoinColumn(name = "Empleado_idEmpleado", referencedColumnName = "idEmpleado", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Empleado empleado;

    public Dia() {
    }

    public Dia(DiaPK diaPK) {
        this.diaPK = diaPK;
    }

    public Dia(Date fecha, int empleadoidEmpleado) {
        this.diaPK = new DiaPK(fecha, empleadoidEmpleado);
    }

    public DiaPK getDiaPK() {
        return diaPK;
    }

    public void setDiaPK(DiaPK diaPK) {
        this.diaPK = diaPK;
    }

    public String getObservacion() {
        return observacion;
    }

    public void setObservacion(String observacion) {
        this.observacion = observacion;
    }

    public Estado getEstadoidEstado() {
        return estadoidEstado;
    }

    public void setEstadoidEstado(Estado estadoidEstado) {
        this.estadoidEstado = estadoidEstado;
    }

    public Turno getTurnoidTurno() {
        return turnoidTurno;
    }

    public void setTurnoidTurno(Turno turnoidTurno) {
        this.turnoidTurno = turnoidTurno;
    }

    public Empleado getEmpleado() {
        return empleado;
    }

    public void setEmpleado(Empleado empleado) {
        this.empleado = empleado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (diaPK != null ? diaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dia)) {
            return false;
        }
        Dia other = (Dia) object;
        if ((this.diaPK == null && other.diaPK != null) || (this.diaPK != null && !this.diaPK.equals(other.diaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Dia[ diaPK=" + diaPK + " ]";
    }
    
}
